package com.example.logindb.repository;

import com.example.logindb.entity.Route;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface RouteRepository extends JpaRepository<Route, Integer> {

    List<Route> findAllByBlindid(int id);

    @Query(value = "SELECT blindid, COUNT(*) AS count " +
            "FROM route " +
            "GROUP BY blindid " +
            "ORDER BY count DESC " +
            "LIMIT 3", nativeQuery = true)
    List<Map<String, Object>> findTopThree();


//    List<String> findGeoJsonByBlindid(int id);
}
